package com.dcliment.display.gui
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	/**
	 * 
	 * @author dcliment
	 * version: 1.0
	 * 
	 */	
	
	public class SimpleRollOverButton extends MovieClip
	{
		private var _selected:Boolean;
		
		public function SimpleRollOverButton()
		{
			
			enable();
			this.gotoAndStop(1);
			
			this.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
		}
		//
		// PUblic functions
		//
		public function enable():void
		{
			
			if(this.hasEventListener(MouseEvent.MOUSE_OVER))
				return;
			
			this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver, false, 0, true);
			this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut, false, 0, true);
			
			this.selected = false;
			this.gotoAndStop(1);
			this.mouseEnabled = this.mouseChildren = true;
			this.buttonMode = true;
			
			
		}
		public function disable():void
		{	
			
			this.removeEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			this.removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			
			this.mouseEnabled = this.mouseChildren = false;
			this.buttonMode = false;
		}
		public function onState():void
		{
			this.disable();
			this.selected = true;
			
			this.gotoAndStop(2);
			
		}
		public function offState():void
		{
			this.enable();
		}
			
		//
		// Private Functions
		//
		protected function onClick(e:MouseEvent):void
		{
			onState();
		}
		protected function onMouseOver(e:MouseEvent):void
		{
			this.gotoAndStop(2);
		}
		protected function onMouseOut(e:MouseEvent):void
		{
			this.gotoAndStop(1);	
		}
		
		//
		// ACCESSORS
		//
		public function get selected():Boolean
		{
			return _selected;
		}

		public function set selected(value:Boolean):void
		{
			_selected = value;
		}
		
		
	}
}